package cs;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class MyClient1 {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        try {
            //192.168.1.190
            Socket s=new Socket("localhost",8888);
            InputStream in=s.getInputStream();
            OutputStream out=s.getOutputStream();
            BufferedReader br=new BufferedReader(new InputStreamReader(in));
            PrintWriter pw=new PrintWriter(out,true);
            while(true){
                System.out.print("聊天:");
                String str=input.next();
                pw.println(str);
                //pw.flush();
                String getStr=br.readLine();
                System.out.println("服务器回复:"+getStr);
                if(str.equals("exit"))
                    break;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
